<template>
  <div class="EMPIAdministration">
    <div class="pubBig Privilege">
      <div class="h0">
        <p class="lt"></p>
      </div>
      <div class="dDownMain">
        <div
          class="twoBox"
          :style="this.$route.query.Token ? 'top:50px;left:10px' : 'top: 100px'"
        >
          <el-row>
            <el-col :span="24">
              <div style="height: 250px; overflow: auto">
                <div>
                  <span
                    style="display: inline-block; margin: 10px; font-size: 16px"
                    >基准信息查询条件</span
                  >
                  <el-button
                    size="small"
                    style="float: right; margin: 10px"
                    @click="getTableData_left"
                    icon="el-icon-search"
                  ></el-button>
                  <el-button
                    size="small"
                    style="float: right; margin: 10px"
                    @click="open"
                    icon="el-icon-plus"
                  ></el-button>
                </div>
                <el-form
                  label-position="right"
                  label-width="80px"
                  :model="formLabelAlign_left"
                >
                  <el-form-item
                    label="主索引："
                    style="display: inline-block; width: 45%"
                  >
                    <el-input
                      v-model="formLabelAlign_left.PatientCode"
                      style="width: 50%"
                    ></el-input>
                  </el-form-item>
                  <!-- <el-form-item
                    label="性别："
                    style="display:inline-block;width:45%"
                  >
                    <el-input
                      v-model="formLabelAlign_left.Gender"
                      style="width:50%"
                    ></el-input>
                  </el-form-item> -->
                  <el-form-item
                    label="姓名："
                    style="display: inline-block; width: 45%"
                  >
                    <el-input
                      v-model="formLabelAlign_left.Name"
                      style="width: 50%"
                    ></el-input>
                  </el-form-item>
                  <!-- <el-form-item
                    label="机构号："
                    style="display:inline-block;width:45%"
                  >
                    <el-input
                      v-model="formLabelAlign_left.type"
                      style="width:50%"
                    ></el-input>
                  </el-form-item> -->
                  <el-form-item
                    label-width="85px"
                    label="身份证号："
                    style="display: inline-block; width: 45%"
                  >
                    <el-input
                      v-model="formLabelAlign_left.CardNo"
                      style="width: 50%"
                    ></el-input>
                  </el-form-item>
                  <el-form-item
                    label-width="85px"
                    label="时间区间："
                    style="display: inline-block; width: 45%"
                  >
                    <el-date-picker
                      v-model="times"
                      type="daterange"
                      align="right"
                      unlink-panels
                      range-separator="至"
                      start-placeholder="开始日期"
                      end-placeholder="结束日期"
                      :picker-options="pickerOptions"
                      format="yyyy - MM - dd "
                      value-format="yyyy-MM-dd"
                    >
                    </el-date-picker>
                  </el-form-item>
                </el-form>
              </div>
              <div style="height: 50%; text-align: center !important">
                <template>
                  <el-table
                    :data="tableData_left"
                    style="width: 100%"
                    :row-key="getRowKeys_left"
                    :expand-row-keys="expands_left"
                    @expand-change="expandSelect_left"
                    @row-click="item_left_click"
                    class="table_left"
                    v-loading="left_table_loading"
                  >
                    <el-table-column type="expand">
                      <template slot-scope="props">
                        <el-button
                          size="mini"
                          style="margin: 5px 20px 5px 30px"
                          @click="item_edit(props.row)"
                          v-show="isDisabled"
                          >编 辑</el-button
                        >
                        <el-button
                          size="mini"
                          style="margin: 5px 20px 5px 30px"
                          v-show="!isDisabled"
                          @click="edit_btnOk"
                          >保 存</el-button
                        >
                        <el-button
                          size="mini"
                          style="margin: 5px"
                          v-show="!isDisabled"
                          @click="isNo"
                          >取 消</el-button
                        >
                        <el-tabs
                          v-model="activeName_left"
                          type="card"
                          @tab-click="handleClick"
                          style="width: 90%; margin-left: 20px"
                        >
                          <el-tab-pane label="服务对象" name="first">
                            <el-form
                              label-position="left"
                              inline
                              class="demo-table-expand"
                              label-width="130px"
                            >
                              <el-form-item label="类别代码">
                                <el-select
                                  v-model="props.row.Category"
                                  placeholder="请选择"
                                  :disabled="isDisabled"
                                  filterable
                                  size="mini"
                                >
                                  <el-option
                                    v-for="item in options_Tel"
                                    :key="item.value"
                                    :label="item.Name"
                                    :value="item.Code"
                                  >
                                  </el-option>
                                </el-select>
                              </el-form-item>
                              <el-form-item label="号码">
                                <el-input
                                  size="mini"
                                  v-model="props.row.IdCard"
                                  :disabled="isDisabled"
                                >
                                </el-input>
                              </el-form-item>
                              <el-form-item label="生效日期">
                                <el-input
                                  size="mini"
                                  v-model="props.row.CreateDate"
                                  :disabled="isDisabled"
                                >
                                </el-input>
                              </el-form-item>
                              <el-form-item label="失效日期">
                                <el-input
                                  size="mini"
                                  v-model="props.row.EffDate"
                                  :disabled="isDisabled"
                                >
                                </el-input>
                              </el-form-item>
                              <el-form-item label="机构名称">
                                <el-input
                                  size="mini"
                                  v-model="props.row.Organization"
                                  :disabled="isDisabled"
                                >
                                </el-input>
                              </el-form-item>
                              <el-form-item label="标识对象">
                                <el-select
                                  v-model="props.row.NameObj"
                                  placeholder="请选择"
                                  :disabled="isDisabled"
                                  size="mini"
                                  filterable
                                >
                                  <el-option
                                    v-for="item in options_NameObj"
                                    :key="item.value"
                                    :label="item.Name"
                                    :value="item.Code"
                                  >
                                  </el-option>
                                </el-select>
                              </el-form-item>
                              <el-form-item label="标识对象代码">
                                <el-select
                                  v-model="props.row.NameObjCode"
                                  placeholder="请选择"
                                  :disabled="isDisabled"
                                  size="mini"
                                  filterable
                                >
                                  <el-option
                                    v-for="item in options_NameObjCode"
                                    :key="item.value"
                                    :label="item.Name"
                                    :value="item.Code"
                                  >
                                  </el-option>
                                </el-select>
                              </el-form-item>
                              <el-form-item label="姓名">
                                <el-input
                                  size="mini"
                                  v-model="props.row.Name"
                                  :disabled="isDisabled"
                                >
                                </el-input>
                              </el-form-item>
                              <el-form-item label="病人类型代码">
                                <el-select
                                  v-model="props.row.TypeCode"
                                  placeholder="请选择"
                                  :disabled="isDisabled"
                                  size="mini"
                                  filterable
                                >
                                  <el-option
                                    v-for="item in options_TypeCode"
                                    :key="item.value"
                                    :label="item.Name"
                                    :value="item.Code"
                                  >
                                  </el-option>
                                </el-select>
                              </el-form-item>
                            </el-form>
                          </el-tab-pane>
                          <el-tab-pane label="个体生物学" name="second">
                            <el-form
                              label-position="left"
                              inline
                              class="demo-table-expand"
                              label-width="130px"
                            >
                              <el-form-item label="ABO 血型">
                                <el-select
                                  v-model="props.row.ABOCode"
                                  placeholder="请选择"
                                  :disabled="isDisabled"
                                  size="mini"
                                  filterable
                                >
                                  <el-option
                                    v-for="item in options_ABO"
                                    :key="item.value"
                                    :label="item.Name"
                                    :value="item.Code"
                                  >
                                  </el-option>
                                </el-select>
                              </el-form-item>
                              <el-form-item label="RH 血型">
                                <el-select
                                  v-model="props.row.RHCode"
                                  placeholder="请选择"
                                  :disabled="isDisabled"
                                  size="mini"
                                  filterable
                                >
                                  <el-option
                                    v-for="item in options_RH"
                                    :key="item.value"
                                    :label="item.Name"
                                    :value="item.Code"
                                  >
                                  </el-option>
                                </el-select>
                              </el-form-item>
                            </el-form>
                          </el-tab-pane>
                          <el-tab-pane label="个体危险性" name="third">
                            <el-form
                              label-position="left"
                              inline
                              class="demo-table-expand"
                              label-width="130px"
                            >
                              <el-form-item label="个体危险性名称">
                                <el-input
                                  size="mini"
                                  v-model="props.row.Risk"
                                  :disabled="isDisabled"
                                >
                                </el-input>
                              </el-form-item>
                              <el-form-item label="个体危险性代码">
                                <el-input
                                  size="mini"
                                  v-model="props.row.RiskCode"
                                  :disabled="isDisabled"
                                >
                                </el-input>
                              </el-form-item>
                            </el-form>
                          </el-tab-pane>
                          <el-tab-pane label="人口学" name="fourth">
                            <el-form
                              label-position="left"
                              inline
                              class="demo-table-expand"
                              label-width="130px"
                            >
                              <el-form-item label="性别代码">
                                <el-select
                                  v-model="props.row.Gender"
                                  placeholder="请选择"
                                  :disabled="isDisabled"
                                  size="mini"
                                  filterable
                                >
                                  <el-option
                                    v-for="item in options_Gender"
                                    :key="item.value"
                                    :label="item.Name"
                                    :value="item.Code"
                                  >
                                  </el-option>
                                </el-select>
                              </el-form-item>
                              <el-form-item label="年龄">
                                <el-input
                                  size="mini"
                                  v-model="props.row.Age"
                                  :disabled="isDisabled"
                                >
                                </el-input>
                              </el-form-item>
                              <el-form-item label="国籍代码">
                                <el-select
                                  v-model="props.row.CountryCode"
                                  placeholder="请选择"
                                  :disabled="isDisabled"
                                  size="mini"
                                  filterable
                                >
                                  <el-option
                                    v-for="item in options_CountryCode"
                                    :key="item.value"
                                    :label="item.Name"
                                    :value="item.Code"
                                  >
                                  </el-option>
                                </el-select>
                              </el-form-item>
                              <el-form-item label="民族代码">
                                <el-select
                                  v-model="props.row.NationCode"
                                  placeholder="请选择"
                                  :disabled="isDisabled"
                                  size="mini"
                                  filterable
                                >
                                  <el-option
                                    v-for="item in options_NationCode"
                                    :key="item.value"
                                    :label="item.Name"
                                    :value="item.Code"
                                  >
                                  </el-option>
                                </el-select>
                              </el-form-item>
                              <el-form-item label="婚姻状况类别代码">
                                <el-select
                                  v-model="props.row.Marital"
                                  placeholder="请选择"
                                  :disabled="isDisabled"
                                  size="mini"
                                  filterable
                                >
                                  <el-option
                                    v-for="item in options_Marital"
                                    :key="item.value"
                                    :label="item.Name"
                                    :value="item.Code"
                                  >
                                  </el-option>
                                </el-select>
                              </el-form-item>
                              <el-form-item
                                label="职业编码系统名称"
                                v-if="false"
                              >
                                <el-input
                                  size="mini"
                                  v-model="props.row.Professional"
                                  :disabled="isDisabled"
                                >
                                </el-input>
                              </el-form-item>
                              <el-form-item label="职业">
                                <el-select
                                  v-model="props.row.ProfessionalCode"
                                  placeholder="请选择"
                                  :disabled="isDisabled"
                                  size="mini"
                                  filterable
                                >
                                  <el-option
                                    v-for="item in options_ProfessionalCode"
                                    :key="item.value"
                                    :label="item.Name"
                                    :value="item.Code"
                                    @click.native="options_Pro_change(item)"
                                  >
                                  </el-option>
                                </el-select>
                              </el-form-item>
                              <el-form-item label="文化程度代码">
                                <el-select
                                  v-model="props.row.EduLevel"
                                  placeholder="请选择"
                                  :disabled="isDisabled"
                                  size="mini"
                                  filterable
                                >
                                  <el-option
                                    v-for="item in options_EduLevel"
                                    :key="item.value"
                                    :label="item.Name"
                                    :value="item.Code"
                                  >
                                  </el-option>
                                </el-select>
                              </el-form-item>
                              <el-form-item label="出生日期">
                                <el-input
                                  size="mini"
                                  v-model="props.row.Born"
                                  :disabled="isDisabled"
                                >
                                </el-input>
                              </el-form-item>
                              <el-form-item label="出生地">
                                <el-input
                                  size="mini"
                                  v-model="props.row.BornAddress"
                                  :disabled="isDisabled"
                                >
                                </el-input>
                              </el-form-item>
                            </el-form>
                          </el-tab-pane>
                          <el-tab-pane label="联系人" name="fifth">
                            <el-form
                              label-position="left"
                              inline
                              class="demo-table-expand"
                              label-width="130px"
                            >
                              <el-form-item label="类别代码">
                                <el-select
                                  v-model="props.row.ContactCateogry"
                                  placeholder="请选择"
                                  :disabled="isDisabled"
                                  size="mini"
                                  filterable
                                >
                                  <el-option
                                    v-for="item in options_ContactObj"
                                    :key="item.value"
                                    :label="item.Name"
                                    :value="item.Code"
                                  >
                                  </el-option>
                                </el-select>
                              </el-form-item>
                              <el-form-item label="号码">
                                <el-input
                                  size="mini"
                                  v-model="props.row.ContactIdCard"
                                  :disabled="isDisabled"
                                >
                                </el-input>
                              </el-form-item>
                              <el-form-item label="生效日期">
                                <el-input
                                  size="mini"
                                  v-model="props.row.ContactCreateDate"
                                  :disabled="isDisabled"
                                >
                                </el-input>
                              </el-form-item>
                              <el-form-item label="失效日期">
                                <el-input
                                  size="mini"
                                  v-model="props.row.ContactEffDate"
                                  :disabled="isDisabled"
                                >
                                </el-input>
                              </el-form-item>
                              <el-form-item label="机构名称">
                                <el-input
                                  size="mini"
                                  v-model="props.row.ContactOrganization"
                                  :disabled="isDisabled"
                                >
                                </el-input>
                              </el-form-item>
                              <el-form-item label="标识对象">
                                <el-select
                                  v-model="props.row.ContactObj"
                                  placeholder="请选择"
                                  :disabled="isDisabled"
                                  size="mini"
                                  filterable
                                >
                                  <el-option
                                    v-for="item in options_ContactObj"
                                    :key="item.value"
                                    :label="item.Name"
                                    :value="item.Code"
                                  >
                                  </el-option>
                                </el-select>
                              </el-form-item>
                              <el-form-item label="标识对象代码">
                                <el-select
                                  v-model="props.row.ContactObjCode"
                                  placeholder="请选择"
                                  :disabled="isDisabled"
                                  size="mini"
                                  filterable
                                >
                                  <el-option
                                    v-for="item in options_ContactObjCode"
                                    :key="item.value"
                                    :label="item.Name"
                                    :value="item.Code"
                                  >
                                  </el-option>
                                </el-select>
                              </el-form-item>
                              <el-form-item label="联系人-姓名">
                                <el-input
                                  size="mini"
                                  v-model="props.row.ContactName"
                                  :disabled="isDisabled"
                                >
                                </el-input>
                              </el-form-item>
                            </el-form>
                          </el-tab-pane>
                          <el-tab-pane label="地址" name="sixth">
                            <el-form
                              label-position="left"
                              inline
                              class="demo-table-expand"
                              label-width="130px"
                            >
                              <el-form-item label="工作单位名称">
                                <el-input
                                  size="mini"
                                  v-model="props.row.Company"
                                  :disabled="isDisabled"
                                >
                                </el-input>
                              </el-form-item>
                              <el-form-item label="地址类别">
                                <el-select
                                  v-model="props.row.AddressCode"
                                  placeholder="请选择"
                                  :disabled="isDisabled"
                                  size="mini"
                                  filterable
                                >
                                  <el-option
                                    v-for="item in options_AddressCode"
                                    :key="item.value"
                                    :label="item.Name"
                                    :value="item.Code"
                                  >
                                  </el-option>
                                </el-select>
                              </el-form-item>
                              <el-form-item label="地址-省">
                                <el-input
                                  size="mini"
                                  v-model="props.row.Province"
                                  :disabled="isDisabled"
                                >
                                </el-input>
                              </el-form-item>
                              <el-form-item label="地址-市">
                                <el-input
                                  size="mini"
                                  v-model="props.row.City"
                                  :disabled="isDisabled"
                                >
                                </el-input>
                              </el-form-item>
                              <el-form-item label="地址-县">
                                <el-input
                                  size="mini"
                                  v-model="props.row.Area"
                                  :disabled="isDisabled"
                                >
                                </el-input>
                              </el-form-item>
                              <el-form-item label="地址-乡">
                                <el-input
                                  size="mini"
                                  v-model="props.row.Countryside"
                                  :disabled="isDisabled"
                                >
                                </el-input>
                              </el-form-item>
                              <el-form-item label="地址-村">
                                <el-input
                                  size="mini"
                                  v-model="props.row.Village"
                                  :disabled="isDisabled"
                                >
                                </el-input>
                              </el-form-item>
                              <el-form-item label="地址-门牌号码">
                                <el-input
                                  size="mini"
                                  v-model="props.row.HouseNumber"
                                  :disabled="isDisabled"
                                >
                                </el-input>
                              </el-form-item>
                              <el-form-item label="邮政编码">
                                <el-input
                                  size="mini"
                                  v-model="props.row.ZipCode"
                                  :disabled="isDisabled"
                                >
                                </el-input>
                              </el-form-item>
                              <el-form-item label="行政区划代码">
                                <el-input
                                  size="mini"
                                  v-model="props.row.DivisionCode"
                                  :disabled="isDisabled"
                                >
                                </el-input>
                              </el-form-item>
                            </el-form>
                          </el-tab-pane>
                          <el-tab-pane label="通信" name="seventh">
                            <el-form
                              label-position="left"
                              inline
                              class="demo-table-expand"
                              label-width="130px"
                            >
                              <el-form-item label="类别" v-if="false">
                                <el-input
                                  size="mini"
                                  v-model="props.row.TelCategory"
                                  :disabled="isDisabled"
                                >
                                </el-input>
                              </el-form-item>
                              <el-form-item label="类别">
                                <el-select
                                  v-model="props.row.TelCategoryCode"
                                  placeholder="请选择"
                                  :disabled="isDisabled"
                                  size="mini"
                                  filterable
                                >
                                  <el-option
                                    v-for="item in options_TelCategoryCode"
                                    :key="item.value"
                                    :label="item.Name"
                                    :value="item.Code"
                                    @click.native="options_Tel_change(item)"
                                  >
                                  </el-option>
                                </el-select>
                              </el-form-item>
                              <el-form-item label="号码">
                                <el-input
                                  size="mini"
                                  v-model="props.row.Telphone"
                                  :disabled="isDisabled"
                                >
                                </el-input>
                              </el-form-item>
                              <el-form-item label="电子邮件地址">
                                <el-input
                                  size="mini"
                                  v-model="props.row.Email"
                                  :disabled="isDisabled"
                                >
                                </el-input>
                              </el-form-item>
                            </el-form>
                          </el-tab-pane>
                          <el-tab-pane label="医保" name="eighth">
                            <el-form
                              label-position="left"
                              inline
                              class="demo-table-expand"
                              label-width="130px"
                            >
                              <el-form-item label="类别" v-if="false">
                                <el-input
                                  size="mini"
                                  v-model="props.row.Medical"
                                  :disabled="isDisabled"
                                >
                                </el-input>
                              </el-form-item>
                              <el-form-item label="类别">
                                <el-select
                                  v-model="props.row.MedicalCode"
                                  placeholder="请选择"
                                  :disabled="isDisabled"
                                  size="mini"
                                  filterable
                                >
                                  <el-option
                                    v-for="item in options_MedicalCode"
                                    :key="item.value"
                                    :label="item.Name"
                                    :value="item.Code"
                                    @click.native="options_Med_change(item)"
                                  >
                                  </el-option>
                                </el-select>
                              </el-form-item>
                            </el-form>
                          </el-tab-pane>
                          <el-tab-pane label="卫生服务机构" name="ninth">
                            <el-form
                              label-position="left"
                              inline
                              class="demo-table-expand"
                              label-width="130px"
                            >
                              <el-form-item label="机构名称">
                                <el-input
                                  size="mini"
                                  v-model="props.row.MedicOrganization"
                                  :disabled="isDisabled"
                                >
                                </el-input>
                              </el-form-item>
                              <el-form-item label="机构组织代码">
                                <el-input
                                  size="mini"
                                  v-model="props.row.MedicOrganizationCode"
                                  :disabled="isDisabled"
                                >
                                </el-input>
                              </el-form-item>
                              <el-form-item label="机构负责人">
                                <el-input
                                  size="mini"
                                  v-model="props.row.MedicLegal"
                                  :disabled="isDisabled"
                                >
                                </el-input>
                              </el-form-item>
                              <el-form-item label="机构地址">
                                <el-input
                                  size="mini"
                                  v-model="props.row.MedicAddress"
                                  :disabled="isDisabled"
                                >
                                </el-input>
                              </el-form-item>
                              <el-form-item label="科室名称">
                                <el-input
                                  size="mini"
                                  v-model="props.row.MedicDepart"
                                  :disabled="isDisabled"
                                >
                                </el-input>
                              </el-form-item>
                              <el-form-item label="机构角色">
                                <el-input
                                  size="mini"
                                  v-model="props.row.MedicOrgRole"
                                  :disabled="isDisabled"
                                >
                                </el-input>
                              </el-form-item>
                              <el-form-item label="机构角色代码">
                                <el-input
                                  size="mini"
                                  v-model="props.row.MedicOrgRoleCode"
                                  :disabled="isDisabled"
                                >
                                </el-input>
                              </el-form-item>
                            </el-form>
                          </el-tab-pane>
                          <el-tab-pane label="卫生服务者" name="tenth">
                            <el-form
                              label-position="left"
                              inline
                              class="demo-table-expand"
                              label-width="150px"
                            >
                              <el-form-item label="服务者平台编码">
                                <el-input
                                  size="mini"
                                  v-model="props.row.MedicCode"
                                  :disabled="isDisabled"
                                >
                                </el-input>
                              </el-form-item>
                              <el-form-item label="服务者姓名">
                                <el-input
                                  size="mini"
                                  v-model="props.row.MedicName"
                                  :disabled="isDisabled"
                                >
                                </el-input>
                              </el-form-item>
                              <el-form-item label="服务者职责">
                                <el-input
                                  size="mini"
                                  v-model="props.row.MedicRole"
                                  :disabled="isDisabled"
                                >
                                </el-input>
                              </el-form-item>
                              <el-form-item label="服务者职责代码">
                                <el-input
                                  size="mini"
                                  v-model="props.row.MedicRoleCode"
                                  :disabled="isDisabled"
                                >
                                </el-input>
                              </el-form-item>
                              <el-form-item label="服务者医师资格标志">
                                <el-input
                                  size="mini"
                                  v-model="props.row.MedicDoctorCert"
                                  :disabled="isDisabled"
                                >
                                </el-input>
                              </el-form-item>
                              <el-form-item label="服务者学历">
                                <el-input
                                  size="mini"
                                  v-model="props.row.MedicEducation"
                                  :disabled="isDisabled"
                                >
                                </el-input>
                              </el-form-item>
                              <el-form-item label="服务者所学专业">
                                <el-input
                                  size="mini"
                                  v-model="props.row.MedicMajor"
                                  :disabled="isDisabled"
                                >
                                </el-input>
                              </el-form-item>
                              <el-form-item label="服务者专业技术职称">
                                <el-input
                                  size="mini"
                                  v-model="props.row.MedicProfessional"
                                  :disabled="isDisabled"
                                >
                                </el-input>
                              </el-form-item>
                              <el-form-item label="服务者职务">
                                <el-input
                                  size="mini"
                                  v-model="props.row.MedicJob"
                                  :disabled="isDisabled"
                                >
                                </el-input>
                              </el-form-item>
                            </el-form>
                          </el-tab-pane>
                        </el-tabs>
                      </template>
                    </el-table-column>
                    <el-table-column label="患者主索引" prop="Code" w>
                    </el-table-column>
                    <el-table-column label="患者姓名" prop="Name">
                    </el-table-column>

                    <el-table-column label="证件类别" prop="CategoryName">
                    </el-table-column>

                    <el-table-column label="证件号码" prop="IdCard">
                    </el-table-column>

                    <el-table-column label="联系电话" prop="Telphone">
                    </el-table-column>

                    <el-table-column label="性别名称" prop="GenderName">
                    </el-table-column>

                    <el-table-column label="出生日期" prop="Born">
                    </el-table-column>

                    <el-table-column label="ABO血型" prop="ABOName">
                    </el-table-column>

                    <el-table-column label="RH血型" prop="RHName">
                    </el-table-column>

                    <el-table-column label="联系人" prop="ContactName">
                    </el-table-column>

                    <!-- <el-table-column
                      label="操作"
                      fixed="right"
                    >
                      <template slot-scope="scope">
                        <el-button
                          size="mini"
                          @click="toView(scope.row)"
                        >CDR</el-button>
                      </template>
                    </el-table-column> -->
                  </el-table>
                </template>
                <div class="block numX">
                  <el-pagination
                    layout="prev, pager, next"
                    :total="page_left.total"
                    :page-size="page_left.limit"
                    @current-change="left_pag_change"
                  >
                  </el-pagination>
                </div>
              </div>
            </el-col>
          </el-row>
          <!-- 弹层 -->
          <el-dialog
            title="添加"
            :visible.sync="dialogVisible"
            width="45%"
            :before-close="handleClose"
            :append-to-body="true"
            :close-on-click-modal="false"
            v-loading="isDialog_loading"
          >
            <el-form
              label-position="right"
              label-width="140px"
              :model="formLabelAlign"
            >
              <el-form-item
                label="姓名："
                style="display: inline-block; width: 50%"
              >
                <el-input
                  v-model="formLabelAlign.Name"
                  size="mini"
                  style="width: 80%"
                ></el-input>
              </el-form-item>
              <el-form-item
                label="证件类型："
                style="display: inline-block; width: 50%"
              >
                <el-select
                  v-model="formLabelAlign.Category"
                  placeholder="请选择"
                  size="mini"
                  filterable
                >
                  <el-option
                    v-for="item in options_Tel"
                    :key="item.value"
                    :label="item.Name"
                    :value="item.Code"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
              <el-form-item
                label="证件号："
                style="display: inline-block; width: 50%"
              >
                <el-input
                  v-model="formLabelAlign.IdCard"
                  size="mini"
                  style="width: 80%"
                ></el-input>
              </el-form-item>
              <el-form-item
                label="联系电话："
                style="display: inline-block; width: 50%"
              >
                <el-input
                  v-model="formLabelAlign.Telphone"
                  size="mini"
                  style="width: 80%"
                ></el-input>
              </el-form-item>
              <el-form-item
                label="性别："
                style="display: inline-block; width: 50%"
              >
                <el-select
                  v-model="formLabelAlign.Gender"
                  placeholder="请选择"
                  size="mini"
                  filterable
                >
                  <el-option
                    v-for="item in options_Gender"
                    :key="item.Code"
                    :label="item.Name"
                    :value="item.Code"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
              <el-form-item
                label="ABO血型："
                style="display: inline-block; width: 50%"
              >
                <el-select
                  v-model="formLabelAlign.ABOCode"
                  placeholder="请选择"
                  filterable
                  size="mini"
                >
                  <el-option
                    v-for="item in options_ABO"
                    :key="item.Code"
                    :label="item.Name"
                    :value="item.Code"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
              <el-form-item
                label="RH血型："
                style="display: inline-block; width: 50%"
              >
                <el-select
                  v-model="formLabelAlign.RHCode"
                  placeholder="请选择"
                  filterable
                  size="mini"
                >
                  <el-option
                    v-for="item in options_RH"
                    :key="item.Code"
                    :label="item.Name"
                    :value="item.Code"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
              <el-form-item
                label="联系人类别："
                style="display: inline-block; width: 50%"
              >
                <el-select
                  v-model="formLabelAlign.ContactCateogry"
                  placeholder="请选择"
                  filterable
                  size="mini"
                >
                  <el-option
                    v-for="item in options_ContactObj"
                    :key="item.Code"
                    :label="item.Name"
                    :value="item.Code"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
              <el-form-item
                label="联系人姓名："
                style="display: inline-block; width: 50%"
              >
                <el-input
                  v-model="formLabelAlign.ContactName"
                  size="mini"
                  style="width: 80%"
                ></el-input>
              </el-form-item>
              <el-form-item
                label="联系人电话："
                style="display: inline-block; width: 50%"
              >
                <el-input
                  v-model="formLabelAlign.ContactIdCard"
                  size="mini"
                  style="width: 80%"
                ></el-input>
              </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
              <el-button @click="handleClose">取 消</el-button>
              <el-button type="primary" @click="btn_ok">确 定</el-button>
            </span>
          </el-dialog>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "",
  data() {
    return {
      formLabelAlign_left: {
        name: "",
        region: "",
        type: "",
      },
      pickerOptions: {
        shortcuts: [
          {
            text: "最近一周",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "最近一个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "最近三个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
              picker.$emit("pick", [start, end]);
            },
          },
        ],
      },
      times: [],
      tableData_left: [],
      activeName_left: "first",
      expands_left: [],
      page_left: {
        total: 1,
        page: 1,
        limit: 20,
      },
      left_table_loading: false,
      // ***************公共********************
      code: null,
      isDisabled: true,
      // ***********************************
      tableData_right_a: [],
      tableData_right_b: [],
      expands_right_a: [],
      isCopyData: [], //编辑时拷贝编辑前数据
      activeName_right_a: "first",
      expands_right_b: [],
      activeName_right_b: "first",
      page_right_a: {
        total: 1,
        page: 1,
        limit: 5,
      },
      page_right_b: {
        total: 1,
        page: 1,
        limit: 5,
      },
      right_table_loading: false,
      // *************************弹层
      dialogVisible: false,
      formLabelAlign: {},
      options_Gender: [], // 性别类别
      options_ABO: [], // ABO血型类别
      options_RH: [], // RH血型类别
      options_ContactObj: [], // 联系人类别
      options_Tel: [], //身份证类别
      options_AddressCode: [], //地址类别
      options_NameObj: [], //姓名类别
      options_NameObjCode: [], //姓名标识对象类别
      options_TypeCode: [], //病人类型类别
      options_CountryCode: [], //所属国籍类别
      options_NationCode: [], //民族类别

      options_Marital: [], //婚姻类别
      options_ProfessionalCode: [], //职业类别
      options_EduLevel: [], //文化程度类别
      options_ContactObjCode: [], //姓名对象类别
      options_TelCategoryCode: [], //联系电话类别
      options_MedicalCode: [], //医疗保险类别
      fromData: {}, //提交保存时的数据
      isDialog_loading: false, //弹层loading
    };
  },
  methods: {
    getTableData_left() {
      var body = {
        page: this.page_left.page,
        limit: this.page_left.limit,
        PatientCode: this.formLabelAlign_left.PatientCode,
        Name: this.formLabelAlign_left.Name,
        CardNo: this.formLabelAlign_left.CardNo,
        StartTime: this.times[0],
        EndTime: this.times[1],
      };
      this.left_table_loading = true;
      this.$post("/Patient/PageList", body).then((res) => {
        if (res.code == 0) {
          this.tableData_left = res.data.list;
          this.page_left.total = res.data.TotalCount;
          this.left_table_loading = false;
        } else if (res.code == -1) {
          this.$message.error(res.msg);
          this.left_table_loading = false;
        }
      });
    },
    handleClick(val) {
      // console.log(val);
    },
    getRowKeys_left: function (row) {
      return row.Code;
    },
    expandSelect_left: function (row, expandedRows) {
      var that = this;
      if (expandedRows.length) {
        that.expands_left = [];
        if (row) {
          that.expands_left.push(row.Code);
          this.activeName_left = "first";
        }
      } else {
        that.expands_left = [];
      }
    },
    item_left_click(row, column, event) {
      this.code = row.Code;
      this.getTableData_right_a();
      this.getTableData_right_b();
    },
    left_pag_change(val) {
      this.page_left.page = val;
      this.getTableData_left();
    },
    toView(val) {
      let Code = val.Code;
      let routeData = this.$router.resolve({ path: "/CDR", query: { Code } });
      // window.open(routeData.href, "_blank");
      this.$router.push(routeData.href);
    },
    // *****************右侧*********************
    getTableData_right_a() {
      this.right_table_loading = true;
      this.$post(
        "/Patient/MergePageList?code=" +
          this.code +
          "&page=" +
          this.page_right_a.page +
          "&limit=" +
          this.page_right_a.limit
      ).then((res) => {
        if (res.code == 0) {
          if (res.data.list == null) {
            this.tableData_right_a = [];
            this.right_table_loading = false;
            return;
          }
          this.tableData_right_a = res.data.list;
          this.page_right_a.total = res.data.TotalCount;
          this.right_table_loading = false;
        } else if (res.code == -1) {
          this.$message.error(res.msg);
          this.right_table_loading = false;
        }
      });
    },
    getTableData_right_b() {
      this.right_table_loading = true;
      this.$post(
        "/Patient/RepeatList?code=" +
          this.code +
          "&page=" +
          this.page_right_b.page +
          "&limit=" +
          this.page_right_b.limit
      ).then((res) => {
        if (res.code == 0) {
          if (res.data.list == null) {
            this.tableData_right_b = [];
            this.right_table_loading = false;
            return;
          }
          this.tableData_right_b = res.data.list;
          this.page_right_b.total = res.data.TotalCount;
          this.right_table_loading = false;
        } else if (res.code == -1) {
          this.$message.error(res.msg);
          this.right_table_loading = false;
        }
      });
    },
    getRowKeys_right_a: function (row) {
      return row.Code;
    },
    expandSelect_right_a: function (row, expandedRows) {
      var that = this;
      if (expandedRows.length) {
        that.expands_right_a = [];
        if (row) {
          that.expands_right_a.push(row.Code);
          this.activeName_right_a = "first";
        }
      } else {
        that.expands_right_a = [];
      }
    },
    getRowKeys_right_b: function (row) {
      return row.Code;
    },
    expandSelect_right_b: function (row, expandedRows) {
      var that = this;
      if (expandedRows.length) {
        that.expands_right_b = [];
        if (row) {
          that.expands_right_b.push(row.Code);
          this.activeName_right_b = "first";
        }
      } else {
        that.expands_right_b = [];
      }
    },
    right_a_pag_change(val) {
      this.page_right_a.page = val;
      this.getTableData_right_a();
    },
    right_b_pag_change(val) {
      this.page_right_b.page = val;
      this.getTableData_right_b();
    },
    btn_right_b_yes(val) {
      this.right_table_loading = true;
      let id = val.Id;
      this.$post("/Patient/DealRepeat?repeatCode=" + id + "&dealType=1").then(
        (res) => {
          if (res.code == 0) {
            this.getTableData_right_a();
            this.getTableData_right_b();
            this.$message({
              message: "合并成功",
              type: "success",
            });
          } else if (res.code == -1) {
            this.right_table_loading = false;
            this.$message.error(res.msg);
          }
        }
      );
    },
    btn_right_b_no(val) {
      this.right_table_loading = true;
      let id = val.Id;
      this.$post("/Patient/DealRepeat?repeatCode=" + id + "&dealType=2").then(
        (res) => {
          if (res.code == 0) {
            this.$message({
              message: "忽略成功",
              type: "success",
            });
            this.getTableData_right_a();
            this.getTableData_right_b();
          } else if (res.code == -1) {
            this.right_table_loading = false;
            this.$message.error(res.msg);
          }
        }
      );
    },
    // **************************弹层
    open() {
      this.dialogVisible = true;
    },
    handleClose() {
      this.dialogVisible = false;
      this.formLabelAlign = {};
    },
    getOptions_Gender() {
      this.$get("/PlatformRange/RangeList?fileCode=GB/T2261.1-2003").then(
        (res) => {
          this.options_Gender = res.data;
        }
      );
    },
    getOptions_ABO() {
      this.$get("/PlatformRange/RangeList?fileCode=CV04.50.005").then((res) => {
        this.options_ABO = res.data;
      });
    },
    getOptions_RH() {
      this.$get("/PlatformRange/RangeList?fileCode=CV04.50.020").then((res) => {
        this.options_RH = res.data;
      });
    },
    getOptions_ContactObj() {
      this.$get("/PlatformRange/RangeList?fileCode=GB/T4761-2008").then(
        (res) => {
          this.options_ContactObj = res.data;
        }
      );
    },
    getOptions_Tel() {
      this.$get("/PlatformRange/RangeList?fileCode=CV02.01.101").then((res) => {
        if (res.code == 0) {
          this.options_Tel = res.data;
        }
      });
    },
    getOptions_AddressCode() {
      this.$get("/PlatformRange/RangeList?fileCode=CV02.01.205").then((res) => {
        if (res.code == 0) {
          this.options_AddressCode = res.data;
          // console.log(res.data);
        }
      });
    },
    getOptions_NameObj() {
      this.$get("/PlatformRange/RangeList?fileCode=CV0100.01").then((res) => {
        if (res.code == 0) {
          this.options_NameObj = res.data;
          // console.log(res.data);
        }
      });
    },
    getOptions_NameObjCode() {
      this.$get("/PlatformRange/RangeList?fileCode=CV0100.02").then((res) => {
        if (res.code == 0) {
          this.options_NameObjCode = res.data;
          // console.log(res.data);
        }
      });
    },
    getOptions_TypeCode() {
      this.$get("/PlatformRange/RangeList?fileCode=CV09.00.404").then((res) => {
        if (res.code == 0) {
          this.options_TypeCode = res.data;
          // console.log(res.data);
        }
      });
    },
    getoptions_CountryCode() {
      this.$get("/PlatformRange/RangeList?fileCode=GB/T2659-2000").then(
        (res) => {
          if (res.code == 0) {
            this.options_CountryCode = res.data;
            // console.log(res.data);
          }
        }
      );
    },
    getoptions_NationCode() {
      this.$get("/PlatformRange/RangeList?fileCode=GB/T3304-1991").then(
        (res) => {
          if (res.code == 0) {
            this.options_NationCode = res.data;
            // console.log(res.data);
          }
        }
      );
    },
    getoptions_Marital() {
      this.$get("/PlatformRange/RangeList?fileCode=GB/T2261.2-2003").then(
        (res) => {
          if (res.code == 0) {
            this.options_Marital = res.data;
            // console.log(res.data);
          }
        }
      );
    },
    getoptions_ProfessionalCode() {
      this.$get("/PlatformRange/RangeList?fileCode=GB/T2261.4-2003").then(
        (res) => {
          if (res.code == 0) {
            this.options_ProfessionalCode = res.data;
            // console.log(res.data);
          }
        }
      );
    },
    getoptions_EduLevel() {
      this.$get("/PlatformRange/RangeList?fileCode=GB/T4658-2006").then(
        (res) => {
          if (res.code == 0) {
            this.options_EduLevel = res.data;
            // console.log(res.data);
          }
        }
      );
    },
    getoptions_ContactObjCode() {
      this.$get("/PlatformRange/RangeList?fileCode=CV0100.02").then((res) => {
        if (res.code == 0) {
          this.options_ContactObjCode = res.data;
          // console.log(res.data);
        }
      });
    },
    getoptions_TelCategoryCode() {
      this.$get("/PlatformRange/RangeList?fileCode=CV0400.01").then((res) => {
        if (res.code == 0) {
          this.options_TelCategoryCode = res.data;
        }
      });
    },
    getoptions_MedicalCode() {
      this.$get("/PlatformRange/RangeList?fileCode=CV02.01.204").then((res) => {
        if (res.code == 0) {
          this.options_MedicalCode = res.data;
        }
      });
    },
    btn_ok() {
      this.isDialog_loading = true;
      this.$post("/Patient/Register", this.formLabelAlign).then((res) => {
        if (res.code == 0) {
          this.getTableData_left();
          this.handleClose();
          this.$message({
            message: "操作成功",
            type: "success",
          });
          this.isDialog_loading = false;
        } else {
          this.$message({
            message: res.msg,
            type: "error",
          });
          this.isDialog_loading = false;
        }
      });
    },
    item_edit(val) {
      this.isDisabled = false;
      // console.log(val);
      this.fromData = val;
      var info = JSON.stringify(this.tableData_left);
      this.isCopyData = JSON.parse(info);
    },
    isNo() {
      this.tableData_left = this.isCopyData;
      this.isDisabled = true;
    },
    edit_btnOk() {
      // console.log(this.tableData_left);
      this.$post("/Patient/Update", this.fromData).then((res) => {
        if (res.code == 0) {
          this.getTableData_left();
          this.isDisabled = true;
          this.$message({
            message: "操作成功",
            type: "success",
          });
        }
      });
    },
    options_Tel_change(val) {
      //联系人电话切换事件
      console.log(val.Name);
      this.tableData_left.TelCategory = val.Name;
      this.tableData_left.TelCategoryCode = val.Code;
      // console.log(this.tableData_left.TelCategory);
    },
    options_Med_change(val) {
      // 医保类别切换事件
      this.tableData_left.Medical = val.Name;
      this.tableData_left.MedicalCode = val.Code;
    },
    options_Pro_change(val) {
      this.tableData_left.Professional = val.Name;
      this.tableData_left.ProfessionalCode = val.Code;
    },
  },
  mounted() {
    this.getTableData_left();
    this.getOptions_Gender();
    this.getOptions_ABO();
    this.getOptions_RH();
    this.getOptions_ContactObj();
    this.getOptions_Tel();
    this.getOptions_AddressCode();
    this.getOptions_NameObj();
    this.getOptions_NameObjCode();
    this.getOptions_TypeCode();
    this.getoptions_CountryCode();
    this.getoptions_NationCode();
    this.getoptions_Marital();
    this.getoptions_ProfessionalCode();
    this.getoptions_EduLevel();
    this.getoptions_ContactObjCode();
    this.getoptions_TelCategoryCode();
    this.getoptions_MedicalCode();
    // document.getElementById("2").focus();
  },
  created() {
    if (this.$route.query.Token) {
      localStorage.setItem("Token", this.$route.query.Token);
    }
  },
};
</script>
<style lang="scss">
.EMPIAdministration {
  .top-input {
    display: inline-block;
    width: 350px;
  }

  .box-top {
    margin-top: 15px;
    margin-left: 5px;
  }
  .demo-table-expand {
    font-size: 0;
  }
  .demo-table-expand label {
    width: 90px;
    color: #99a9bf;
  }
  .demo-table-expand .el-form-item {
    margin-right: 0;
    margin-bottom: 0;
    width: 50%;
  }
  .table_left .el-table__body-wrapper {
    overflow-y: auto;
    position: relative;
    height: 420px !important;
  }
  .el-tabs--border-card > .el-tabs__content {
    height: 655px;
  }
  .numX {
    display: inline-block;
  }
}
</style>
